.TH std::basic_string_view::max_size 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::basic_string_view::max_size \- std::basic_string_view::max_size

.SH Synopsis
   constexpr size_type max_size() const noexcept;  \fI(since C++17)\fP

   The largest possible number of char-like objects that can be referred to by a
   basic_string_view.

.SH Parameters

   \fI(none)\fP

.SH Return value

   Maximum number of characters.

.SH Complexity

   Constant.

.SH Example


// Run this code

 #include <cstdint>
 #include <iostream>
 #include <limits>
 #include <string_view>

 int main()
 {
     std::cout << std::numeric_limits<std::int64_t>::max()
               << " <- numeric_limits<int64_t>::max()\\n"
               << std::string_view{}.max_size()
               << " <- string_view::max_size()\\n"
               << std::basic_string_view<char>{}.max_size()
               << " <- basic_string_view<char>::max_size()\\n"
               << std::basic_string_view<char16_t>{}.max_size()
               << " <- basic_string_view<char16_t>::max_size()\\n"
               << std::wstring_view{}.max_size()
               << " <- wstring_view::max_size()\\n"
               << std::basic_string_view<char32_t>{}.max_size()
               << " <- basic_string_view<char32_t>::max_size()\\n";
 }

.SH Possible output:

 9223372036854775807 <- numeric_limits<int64_t>::max()
 4611686018427387899 <- string_view::max_size()
 4611686018427387899 <- basic_string_view<char>::max_size()
 2305843009213693949 <- basic_string_view<char16_t>::max_size()
 1152921504606846974 <- wstring_view::max_size()
 1152921504606846974 <- basic_string_view<char32_t>::max_size()

.SH See also

   size     returns the number of characters
   length   \fI(public member function)\fP
   empty    checks whether the view is empty
            \fI(public member function)\fP
            returns the maximum number of characters
   max_size \fI(public member function of std::basic_string<CharT,Traits,Allocator>)\fP

